import request,{createService} from '@utils/request'
import BASE_URL,{tokenKey} from '../javaBaseUrl'
const javaRequest = createService(BASE_URL,tokenKey)
//考核组织列表
export const getOrgList = (data) => {
    return request.get(`/api/per/org/orgList?pid=${data.pid}&page=${data.pageNo}&pagesize=${data.pageSize}`)
}
// /permission/dept/lazy 根据Pid获取组织数据-懒加载
export const getDeptLazy = (data) => {
    return javaRequest.get(`/permission/dept/lazy?pid=${data.pid}`)
}
export const getDeptSuperior = (data) => {
    return javaRequest.post(`/permission/dept/superior`,data)
}
// 查询所有菜单的树结构
export const getAllDept = (data) => {
    return javaRequest.get(`/permission/dept`)
}


//考核组织新增
export const orgAdd = (data) => {
    return request.post(`/api/per/org/addOrg`, data)
}
//考核组织编辑
export const orgEdit = (data) => {
    return request.post(`/api/per/org/saveOrg`, data)
}
//考核组织删除
export const orgDel = (data) => {
    return request.get(`/api/per/org/delOrg?id=${data}`)
}
//考核组织人员列表
export const getOrgPeopleList = (data) => {
    return request.get(`/api/per/org/people/peopleList?orgid=${data.orgid}&page=${data.pageNo}&pagesize=${data.pageSize}`)
}
//考核组织人员新增
export const orgPeopleAdd = (data) => {
    return request.post(`/api/per/org/people/addPeople`, data)
}
//考核组织人员编辑
export const orgPeopleEdit = (data) => {
    return request.post(`/api/per/org/people/savePeople`, data)
}
//考核组织人员删除
export const orgPeopleDel = (data) => {
    return request.get(`/api/per/org/people/delPeople?id=${data}`)
}

//禅道用户列表
// export const userList = (data) => {
//     return request.get(`/api/user/userList?page=${data.pageNo}&pagesize=${data.pageSize}`)
// }
export const userList = (data) => {
    return javaRequest.get(`/user`,{params:data})
}
// //提那家禅道用户
// export const addUser = (data) => {
//     return request.post(`/api/user/addUser`, data)
// }
// 用户管理--新增用户
export const addUser = (data) => {
    return javaRequest.post(`/user`, data)
}
// 用户管理--修改用户
export const editUser = (data) => {
    return javaRequest.put(`/user`, data)
}
//删除禅道用户
export const delUser = (data) => {
    return request.get(`/api/user/delUser?id=${data}`)
}
//depart_spot为1的组织架构列表
export const getOrgListTj = (data) => {
    return request.get(`/api/per/org/orgListTj?month=${data.month}&pid=${data.pid}&uid=${data.uid}&page=${data.pageNo}&pagesize=${data.pageSize}`)
}
//考核组织人员列表（统计排名处使用）
export const getOrgPeopleListTj = (data) => {
    return request.get(`/api/per/org/people/peopleListTj?month=${data.month}&orgid=${data.orgid}&uid=${data.uid}&page=${data.pageNo}&pagesize=${data.pageSize}`)
}

export default {
    getOrgList, orgAdd, orgEdit, orgDel,
    getOrgPeopleList, orgPeopleAdd, orgPeopleEdit, orgPeopleDel,
    userList, addUser, delUser, getOrgListTj, getOrgPeopleListTj,
    editUser, getDeptLazy, getDeptSuperior, getAllDept
}